home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freelog 125
/
Freelog_MarsAvril2015_No125.iso
/
Musique
/
Quod Libet
/
quodlibet-3.3.0-installer.exe
/
bin
/
quodlibet
/
player
/
_base.pyc
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2014-12-31
|
7KB
|
209 lines
# Source Generated with Decompyle++
# File: in.pyc (Python 2.7)
from gi.repository import GObject
from quodlibet.formats._audio import AudioFile
class Equalizer(object):
_eq_values = []
def eq_bands(self):
'''read-only list of equalizer bands (in Hz) supported.'''
return []
eq_bands = property(eq_bands)
def eq_values(self):
'''The list of equalizer values, in the range (-24dB, 12dB).'''
return self._eq_values
eq_values = property(eq_values)
def eq_values(self, value):
self._eq_values[:] = value
self.update_eq_values()
eq_values = eq_values.setter(eq_values)
def update_eq_values(self):
'''Override to apply equalizer values'''
pass
class BasePlayer(GObject.GObject, Equalizer):
"""Interfaces between a QL PlaylistModel and a GSt playbin.
Attributes:
paused -- True or False, set to pause/unpause the player
volume -- current volume, 0.0 to 1.0
song -- current song, or None if not playing
info -- current stream information, or None if not playing. This is
usually the same as song, unless the user is listening to
a stream with multiple songs in it.
If you're going to show things, use .info. If you're going to
change things, use .song.
"""
name = ''
version_info = ''
paused = None
song = None
info = None
volume = None
error = False
replaygain_profiles = [
None,
None,
None,
[
'none']]
_volume = 1
_paused = True
_source = None
_gsignals_ = {
'song-started': (GObject.SignalFlags.RUN_LAST, None, (object,)),
'song-ended': (GObject.SignalFlags.RUN_LAST, None, (object, bool)),
'seek': (GObject.SignalFlags.RUN_LAST, None, (object, int)),
'paused': (GObject.SignalFlags.RUN_LAST, None, ()),
'unpaused': (GObject.SignalFlags.RUN_LAST, None, ()),
'error': (GObject.SignalFlags.RUN_LAST, None, (object, object)) }
_gproperties_ = {
'volume': (float, 'player volume', 'the volume of the player', 0, 1, 1, GObject.PARAM_READWRITE) }
def __init__(self, *args, **kwargs):
super(BasePlayer, self).__init__()
def destroy(self):
'''Free resources'''
if self.song is not self.info:
self.emit('song-ended', self.info, True)
self.emit('song-ended', self.song, True)
self._source = None
self._destroy()
def do_get_property(self, property):
if property.name == 'volume':
return self._volume
raise None
def _set_volume(self, v):
self.props.volume = min(1, max(0, v))
volume = property((lambda s: s._volume), _set_volume)
def _destroy(self):
'''Clean up'''
raise NotImplementedError
def _end(self, stopped, next_song = None):
"""Start playing the current song from the source or
next_song if it isn't None.
"""
raise NotImplementedError
def setup(self, source, song, seek_pos):
'''Connect to a PlaylistModel, and load a song.
seek_pos in millisecs
'''
if not source is not None:
raise AssertionError
if None._source is None:
self.emit('song-started', song)
self._source = source
self.go_to(song, explicit = True)
if seek_pos:
self.seek(seek_pos)
def seek(self, position):
'''Seek to absolute position in milliseconds.
If position is larger than the duration start the next song
'''
raise NotImplementedError
def get_position(self):
'''The current position in milliseconds'''
raise NotImplementedError
def remove(self, song):
"""Make sure the song isn't played anymore"""
if song and self.song is song:
self._source.next()
self._end(True)
def stop(self):
'''Stop playback and reset the position.
Might release the audio device
'''
self.paused = True
self.seek(0)
def reset(self):
'''Reset the source and start playing if possible'''
self._source.reset()
if self._source.current is not None:
self._end(True)
if self.song:
self.paused = False
def next(self):
'''Move to the next song'''
self._source.next()
self._end(True)
if self.song:
self.paused = False
def previous(self, force = False):
'''Go back if standing at the beginning of the song
otherwise restart the current song.
If force is True always go back.
'''
if force or self.get_position() < 1500:
self._source.previous()
self._end(True)
else:
self.seek(0)
if self.song:
self.paused = False
def go_to(self, song_or_iter, explicit = False):
'''Activate the song or iter in the playlist if possible and play it.
Explicit if the action comes from the user.
Returns True if there is an active song after the call returns.
'''
print_d('Going to %r' % getattr(song_or_iter, 'key', song_or_iter))
if self._source.go_to(song_or_iter, explicit):
self._end(True)
elif isinstance(song_or_iter, AudioFile):
self._end(True, song_or_iter)
elif explicit:
return None
self._end(True)
return self.song is not None
def can_play_uri(self, uri):
'''Whether the player supports playing te given URI scheme'''
raise NotImplementedError